<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.util.*, myclasses.*, support.*, java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Specialization</title>
</head>
<h3>Please select your specialization</h3>
<body>
<form action ="verification.jsp" method="get">
<p>Select specialization: <select name="specialization" >

<option value="Not selected">Select one</option>
<%
	try {
		Class.forName("org.postgresql.Driver");
	} catch(Exception e) {
		out.println("org.postgresql.Driver Exception. ");
	}
	
	try {
		String serverName = "localhost:5432";
	    String mydatabase = "ThirdBase";
	    String url = "jdbc:postgresql://" + serverName + "/" + mydatabase; 
	    String username = "SweetAss";
	    String password = "1234";
	    Connection conn = DriverManager.getConnection(url, username, password);
	    
		Statement stmt = conn.createStatement();
	
		ResultSet rset = stmt.executeQuery("SELECT id,name FROM specialization");
	
		while (rset.next()) {
			out.println("<option value=\"" + rset.getString(1) + "\">" + rset.getString(2) +"</option>");	
		}
		
		rset.close();
		stmt.close();
		conn.close();
	
	} catch(SQLException e) {
		e.printStackTrace();
		out.println("Connection exception.");
	}
	
%>

</select></p>

<input type="submit" value="Submit"/>
</form>
</body>
</html>